{include file="public/header" /}
<style>
    /*.offer{*/
        /*margin-left: 50%;*/
    /*}*/
    /*#other_offer_id{*/
        /*margin-left: 40%;*/
    /*}*/
    /*#province{*/
        /*margin-left: 10%;*/
    /*}*/
    .btn_bj{
        cursor:pointer;
    }
    .sub{
        cursor:pointer;
    }
</style>
<script src="__JS__/lCalendar.min.js"></script>
<link rel="stylesheet" type="text/css" href="__CSS__/lCalendar.css">
<body>

	
	<!--header start-->
    <header>
    	<div class="header">
        	<a href="javascript:history.go(-1);" class="fan"></a>
        	<h1>个人资料</h1>
        </div>
    </header>
    <!--header end-->
    
    <!--main start-->
    <div class="my_one">
    	<img src="{$info['head_img']}" class="img">
        <div class="left">
            <span class="name">{$info['nickname']}</span>
            <span class="wxID">微信号：{$info['wx_code']}</span>
            <span class="dz">{$info['p_city']}</span>
        </div>
<!--        <span id="note" data-uid="{$info['id']}" class="ly">-->
<!--        	对她留言-->
<!--        </span>-->
    </div>
    
    <div class="in_one">
        <i class="i1"></i>
        <span>个人资料</span>
        <input type="button" class="btn btn_bj" value="编辑">
    </div>
    <ul class="in_two">
        <li>
            <span class="ll">微信号:</span>
            <span class="rr">{$info['wx_code']}</span>
            <input id="wx_code" type="text" class="txt rr_xiang" placeholder="请输入">
        </li>
        <li>
            <span class="ll">出生日期: </span>
            <span data-lcalendar="1980-01-01,2002-12-31" class="rr">{$info['birth']}</span>
            
            <input id="birth" type="text" class="txt rr_xiang" placeholder="请输入">
        </li>
        <li>
            <span class="ll">家乡:</span>
            <select name="" id="province">
                {volist name="areaList" id="vo"}
                <option value="{$vo.id}"  {if condition="$vo['id'] eq $info['home_province']"} selected {/if} >{$vo.name}</option>
                {/volist}
            </select>
            <select name="" id="city">
                {volist name="cityList" id="vo"}
                <option value="{$vo.id}"  {if condition="$vo['id'] eq $info['home_city']"} selected {/if} >{$vo.name}</option>
                {/volist}
            </select>
        </li>
        <li>
            <span class="ll">学历:</span>
            <select class="offer" name="" id="offer_id">
                {volist name="offer_list" id="vo"}
                <option value="{$vo.id}"  {if condition="$vo['id'] eq $info['offer_id']"} selected {/if} >{$vo.name}</option>
                {/volist}
            </select>

<!--            <input type="text" class="txt rr_xiang" placeholder="请输入">-->
        </li>
        <li>
            <span class="ll">毕业院校:</span>
            <span class="rr">{$info['college']}</span>
            <input id="college" type="text" class="txt rr_xiang" placeholder="请输入">
        </li>
        <li>
            <span class="ll">工作单位:</span>
            <span class="rr">{$info['work']}</span>
            <input id="work" type="text" class="txt rr_xiang" placeholder="请输入">
        </li>
        <li>
            <span class="ll">身高:</span>
            <span class="rr">{$info['height']}cm</span>
            <input id="height" type="text" class="txt rr_xiang" placeholder="请输入">
        </li>
    </ul>
    
    <div class="in_one">
        <i class="i2"></i>
        <span>择偶标准</span>
        <input type="button" class="btn btn_bj" value="编辑">
    </div>
    <ul class="in_two"> 
        <li>
            <span class="ll">年龄:</span>
            <select id="other_age">
                <option value="0">请选择年龄范围</option>
                <option value="20-25" {if condition="'20-25' eq $info['other_age']"} selected {/if} >20-25</option>
                <option value="25-30" {if condition="'25-30' eq $info['other_age']"} selected {/if} >25-30</option>
                <option value="30-35" {if condition="'30-35' eq $info['other_age']"} selected {/if} >30-35</option>
            </select>
            <!--<span class="rr">{$info['min_age']} ~ {$info['max_age']}岁</span>-->
            <!--<input id="other_age" type="text" class="txt rr_xiang" placeholder="请输入,如:20~35">-->
        </li>
        <li>
            <span class="ll">学历:</span>
            <select name="" id="other_offer_id">
                {volist name="offer_list" id="vo"}
                <option value="{$vo.id}"  {if condition="$vo['id'] eq $info['other_offer_id']"} selected {/if} >{$vo.name}以上</option>
                {/volist}
            </select>

        </li>
        <li>
            <span class="ll">身高:</span>
            <select id="other_height">
                <option value="0">请选择身高范围</option>
                <option value="150-160" {if condition="'150-160' eq $info['other_height']"} selected {/if}>150-160</option>
                <option value="160-170" {if condition="'160-170' eq $info['other_height']"} selected {/if}>160-170</option>
                <option value="170-180" {if condition="'170-180' eq $info['other_height']"} selected {/if}>170-180</option>
                <option value="180" {if condition="'180' eq $info['other_height']"} selected {/if}>180以上</option>
            </select>
            <!--<span class="rr">{$info['min_height']} ~ {$info['max_height']}cm</span>-->
            <!--<input id="other_height" type="text" class="txt rr_xiang" placeholder="请输入,如:160~170">-->
        </li>
    </ul>
    
    <!--<div class="in_one">-->
        <!--<i class="i3"></i>-->
        <!--<span>兴趣爱好</span>-->
        <!--<input type="button" class="btn btn_bj" value="编辑">-->
    <!--</div>-->
    <!--<div class="in_two">-->
        <!--<div class="desc">-->
            <!--简介：{$info['habit']}-->
        <!--</div>-->
        <!--<textarea id="habit" class="txt_js" placeholder="请输入内容"></textarea>-->
    <!--</div>-->
    <div class="in_one">
        <i class="i3"></i>
        <span>兴趣爱好</span>
        <input type="button" class="btn btn_bj" value="编辑">
    </div>
    <div class="in_two">
        <dl class="aihao">
            <!--<dd>吃饭<i class="close">X</i></dd>-->
            <!--<dd>打游戏<i class="close">X</i></dd>-->
            <!--<dd>旅游<i class="close">X</i></dd>-->

            {volist name="tagList" id="vo"}
            <input type="checkbox" name="habit[]" value="{$vo.id}"  {in  name="$vo['id']" value="$info.habit"}checked{/in} >{$vo.name}
            {/volist}

        </dl>
        <p class="p_add">
            <input id="tag_name" type="text" class="txt1" placeholder="请输入">
            <input id="addTag" type="button" class="btn_add" value="添加">
        </p>
    </div>
    
    <div class="in_one">
        <i class="i4"></i>
        <span>家庭介绍</span>
        <input type="button" class="btn btn_bj" value="编辑">
    </div>
    <div class="in_two">
        <div class="desc">
            {$info['home_intro']}
        </div>
        <textarea id="home_intro" class="txt_js rr" placeholder="请输入内容"></textarea>
    </div>
    
    <div class="in_one">
        <i class="i5"></i>
        <span>个人介绍</span>
        <input type="button" class="btn btn_bj" value="编辑">
    </div>
    <div class="in_two">
        <div class="desc">
            {$info['self_intro']}
        </div>
        <textarea id="self_intro" class="txt_js" placeholder="请输入内容"></textarea>
    </div>

    <!--main end-->

    <script type="text/javascript">
        var calendar = new lCalendar();
        calendar.init({
            'trigger': '#birth',
            'type': 'date'
        });
    $(function(){
		$(".btn_bj").click(function(){
			var i=$(".btn_bj").index(this);
			if($(this).val()=="编辑"){
				$(this).val("保存");
				$(this).addClass('sub');
				$(".in_two:eq("+i+") .rr").hide();
				$(".in_two:eq("+i+") .desc").hide();	
				$(".in_two:eq("+i+") .rr_xiang").show();
                $(".in_two:eq("+i+") .p_add").show();
				$(".in_two:eq("+i+") .txt_js").show();
                $(".in_two:eq("+i+") .aihao .close").show();
			}
			else{

                var uid = {$uid};

                var birth = $('#birth').val();
                var wx_code = $('#wx_code').val();
                var home_province = $('#province').val();
                var home_city = $('#city').val();
                var offer_id = $('#offer_id').val();
                var college = $('#college').val();
                var work = $('#work').val();
                var height = $('#height').val();
                var other_age = $('#other_age').val();
                var other_offer_id = $('#other_offer_id').val();
                var other_height = $('#other_height').val();
                var habit = $('#habit').val();
                var home_intro = $('#home_intro').val();
                var self_intro = $('#self_intro').val();
                $.post("{:url('index/User/edit')}", {'id':uid,'wx_code':wx_code,'birth':birth,'home_province':home_province,'home_city':home_city,'offer_id':offer_id,'college':college,'work':work,'height':height,'other_age':other_age,'other_offer_id':other_offer_id,'other_height':other_height,'habit':habit,'home_intro':home_intro,'self_intro':self_intro}, function (res) {
                    if (res.code == 1) {
                        layer.msg(res.msg, {time: 2000, icon: 1});
                        location.href = "{:url('index/Index/index')}";
                    } else {
                        layer.msg(res.msg, {time: 2000, icon: 2});
                    }
                });
				// $(this).val("编辑");
				// $(".in_two:eq("+i+") .rr").show();
				// $(".in_two:eq("+i+") .desc").show();
				// $(".in_two:eq("+i+") .rr_xiang").hide();
				// $(".in_two:eq("+i+") .txt_js").hide();
			}
		})
        $("#note").click(function(){
            var uid = $(this).data('uid');
            layer.prompt({title: '填写留言，并确认', formType: 2}, function(text, index){
                layer.close(index);
                if(text){
                    // layer.alert(uid)
                    $.post("{:url('index/Note/add')}", {'uid':uid,'content':text}, function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {time: 1000, icon: 1});
                        } else {
                            layer.msg(res.msg, {time: 1000, icon: 2});
                        }
                    });
                }
            });
        })

        $('#addTag').click(function () {
            var name = $('#tag_name').val();
            if(!name){
                layer.msg('不能为空', {time: 2000, icon: 2});
                return false;
            }
            $.post("{:url('index/User/addTag')}", {'name':name}, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, {time: 2000, icon: 1});
                    location.reload();
                } else {
                    layer.msg(res.msg, {time: 2000, icon: 2});
                }
            });

        })
	})
        $('#province').change(function () {
            var province_id = $('#province').val();
            $.get('{:url("index/User/member_area")}?id='+province_id, function (res) {
                if(res){
                    var html = '';
                    for (var i=0 ;i<res.length;i++){
                        html += "<option value="+res[i]['id']+">"+res[i]['name']+"</option>";
                    }
                    $('#city').html(html);
                }
            });
        })
    </script>
    
</body>
</html>
